<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .phone_border {
            width: 375px;
            height: 400px;
            overflow: hidden;
            margin: auto;
            position: relative;
        }

        .phone_border img {
            position: absolute;
            top: 0px;
        }
    </style>
</head>

<body>
    <div id="phone_border" class="phone_border">
        <img class="previewImg" id="previewImg" src="./1-1首页-默认.png" alt="">
    </div>
    <script>
        let preview = document.getElementById('previewImg')
        let hovering = false
        let baseTop = 0
        let timer
        document.getElementById('phone_border').addEventListener('mouseover', function () {

            timer = setInterval(() => {
                baseTop = baseTop - 50
                preview.style.top = baseTop + 'px'
                console.log(baseTop)
            }, 100);
        })
        document.getElementById('phone_border').addEventListener('mouseout', function () {
            hovering = false
            baseTop = 0
            preview.style.top = baseTop + 'px'
            clearInterval(timer)
        })
    </script>
</body>

</html>